<?php
/*
 *
 */
class action extends app{
	public function display(){
		$action = $this->routes->url(3);
		if(!method_exists($this,$action))
		$action = "view";
		$this->$action();
		exit;
	}

	private function view(){
		$page = intval($this->routes->get('page'));
		$page = $page>0?$page:1;	
		$Catalog=$this->routes->get('catalog_name');
		$MyCat=$this->category->getOneByCatalog($Catalog);
		if($MyCat){
			$ListApps=$this->apps->getAllByData();
			$cids=$this->category->getCids(array('parent_id'=>$MyCat['id']));
			if($cids){
				$cids=$cids.','.$MyCat['id'];
			}else{
				$cids=$MyCat['id'];
			}
			$condition="FIND_IN_SET(cat_id,'".$cids."')";
			$ListArt=$this->article->getList($page,$MyCat['cat_pagenum'],$condition,'list');
			if($page>$ListArt['total']&&$page>1){
				$message = array(
					'statusCode' =>300,
					"message" => "请勿乱策",
					"callbackType" =>'forward',
					"forwardUrl" =>"list1.html"
				);
				$this->G->R($message);
			}
			$NavCrumb=$this->category->getNavCrumbByCid($MyCat['id']);
			$ListCatSun=$this->category->getSunByCid($MyCat['id']);
			$ListArtHot=$this->article->getSpecialArt($MyCat['id'],$MyCat['cat_pagenum'],'view desc');
			$ListArtNew=$this->article->getSpecialArt($MyCat['id'],$MyCat['cat_pagenum'],'addtime desc');
			$this->tpl->assign("ListArtNew",$ListArtNew);
			$this->tpl->assign("ListArtHot",$ListArtHot);
			$this->tpl->assign("ListApps",$ListApps);		
			$this->tpl->assign("MyCat",$MyCat);
			$this->tpl->assign("NavCrumb",$NavCrumb);
			$this->tpl->assign("Catalog",$Catalog);
			$this->tpl->assign("ListArt",$ListArt);
			$this->tpl->assign("ListCatSun",$ListCatSun);
			$SeoTitle=$MyCat['seo_title']!=''?$MyCat['seo_title']:$MyCat['cat_name'];
			$SeoKeywords=$MyCat['seo_keywords']!=''?$MyCat['seo_keywords']:$MyCat['cat_name'];
			$SeoDescription=$MyCat['seo_description']!=''?$MyCat['seo_description']:$MyCat['cat_name'];
			if($page>1){
				$this->tpl->assign("SeoTitle",$SeoTitle.' 第'.$page.'页');
			}else{
				$this->tpl->assign("SeoTitle",$SeoTitle);
			}
			$this->tpl->assign("SeoKeywords",$SeoKeywords);
			$this->tpl->assign("SeoDescription",$SeoDescription);
            if($MyCat['cat_skin']){
                $this->tpl->display($MyCat['cat_skin']);
            }else{
                $this->tpl->display('category_view');
            }			
		}else{
			header("location:/404.html");
		}			
	}
}
?>
